<?php

namespace Home\Model;

use Think\Model;

/**
 * 分类模型
 */
class AdModel extends Model
{

    const TYPE_AD = 1; // advertisement
    const TYPE_FL = 2; // friendly link

    const TYPE_AD_NAME = 'Advert'; // advertisement
    const TYPE_FL_NAME = 'Friend'; // friendly link

    # 位置
    # 1~10
    const POSITION_INDEX_TOP = 1; // 首页
    const POSITION_INDEX_CHANNEL_1 = 2; // 首页-进入频道首页1
    const POSITION_INDEX_CHANNEL_2 = 3; // 首页-进入频道首页2
    # end-1~10
    # END-位置

    public function lists($where)
    {
        return $this->where($where)->select();
    }


    /**
     * [getAdPositionList 获取广告指定位置列表]
     * @param  [type] $position [description]
     * @return [type]           [description]
     */
    public function getAdPositionList($position)
    {
        $where = array();
        $where['status'] = 1;
        $where['type'] = self::TYPE_AD;
        $where['position'] = $position;
//        if($position){
//            $where[] = "position & {$position} = {$position}";
//        }
        return $this->where($where)->select();
    }


    /**
     * [getAdPositionRow 获取广告指定位置单条数据]
     * @param  [type] $position [description]
     * @return [type]           [description]
     */
    public function getAdPositionRow($position)
    {
        $where = array();
        $where['status'] = 1;
        $where['type'] = self::TYPE_AD;
        $where['position'] = $position;
        return $this->where($where)->find();
    }


    /**
     * [getAdPositionList 获取广告指定位置列表]
     * @param  [type] $position [description]
     * @return [type]           [description]
     */
    public function getFLPositionList($position = 0)
    {
        $where = array();
        $where['status'] = 1;
        $where['type'] = self::TYPE_AD;
        $where['position'] = $position;
//        if($position){
//            $where[] = "position & {$position} = {$position}";
//        }
        return $this->where($where)->select();
    }

}
